Matri = {
	init: function() {
		$('#cmbDistID').change(function(){
			url = "ajax_handler.php" + "?id="+$('#cmbDistID').val()+"&key=MAT_DIST";
			$.get(url, {
				parent_id: $('#cmbDistID').val(),
			}, function(response){
				setTimeout("finishAjax('showcity', '"+escape(response)+"')", 100);
			});
			return false;
		});
	}
};
$(document).ready(function() {

	
	$('#cmbcontState').change(function(){
		url = "ajax_handler.php" + "?id="+$('#cmbcontState').val()+"&key=STATE";
		$.get(url, {
			parent_id: $('#cmbcontState').val(),
		}, function(response){
			setTimeout("finishAjax('showdists', '"+escape(response)+"')", 100);
		});
		return false;
	});
	$('#cmbStateID').change(function(){
		url = "ajax_handler.php" + "?id="+$('#cmbStateID').val()+"&key=MAT_STATE";
		$.get(url, {
			parent_id: $('#cmbStateID').val(),
		}, function(response){
			setTimeout("finishAjax('showdist', '"+escape(response)+"')", 100);
		});
		return false;
	});
	Matri.init();
});

function finishAjax(id, response){
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
  Matri.init();
} 

function alert_id()
{
	if($('#sub_category_id').val() == '')
	alert('Please select a sub category.');
	else
	alert($('#sub_category_id').val());
	return false;
}
